import os, sys, datetime
from google.appengine.ext import db
from google.appengine.api import namespace_manager

GLOBAL_NAMESPACE = '-global-'

def get_absolute_path(app_root_path):
     dir_path = os.path.dirname(__file__)
     parent_dir_path , dir_name = os.path.split(dir_path) 
     return os.path.join(parent_dir_path, app_root_path)


def get_localized_current_datetime():
    return datetime.datetime.utcnow() + datetime.timedelta(hours=7)


def print_debug_msg(msg):
    sys.stderr.write('===' + msg + '\n')


def loadApplicationInfo():
    app = None
    # Use only one instance of ApplicationInfo in data store
    models = ApplicationInfo.all().fetch(1)
    if len(models) > 0:
        app = models[0]
    else:
        app = ApplicationInfo()
        
    return app

        

class ApplicationInfo(db.Model):
    appId = db.StringProperty()
